//
//  CustomNoteImageview.m
//  DogeLegs
//
//  Created by 宋华 on 2017/8/19.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "CustomNoteImageview.h"
#import "ImageMode.h"

@interface CustomNoteImageview () {


}

@property (weak, nonatomic) IBOutlet UIImageView *itemImageview;

@property (weak, nonatomic) IBOutlet UIButton *closeBtn;

- (IBAction)close:(id)sender;

@end

@implementation CustomNoteImageview


- (void)awakeFromNib {
    [super awakeFromNib];
}


#pragma mark -action事件
- (IBAction)close:(id)sender {
    if (self.deletePicBlock) {
        self.deletePicBlock(self.imageIndex);
    }
}


#pragma mark -setter
- (void)setIsShowDeleteBtn:(BOOL)isShowDeleteBtn {
    _isShowDeleteBtn = isShowDeleteBtn;
    self.closeBtn.hidden = !_isShowDeleteBtn;
}

- (void)setImage:(ImageMode *)imageMode {
    if (imageMode.sourceType == ImageSourceType_local) {
        self.itemImageview.image = imageMode.localImg;
    } else if (imageMode.sourceType == ImageSourceType_net) {
        [self.itemImageview sd_setImageWithURL:[NSURL URLWithString:imageMode.imageUrl] placeholderImage:[UIImage imageNamed:@"addImage"]];
    }
}

@end
